﻿using AutoMapper;
using Common.Communal;
using ERP.Domain.CustomerSupplier;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Sell.Api.Write.Application.Command.CustomerCommand;

namespace Sell.Api.Write.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class CustomerController : ControllerBase
    {
        public IMediator Mediator {  get; }
        public ILogger<CustomerController> Logger { get; }
        public CustomerController(IMediator _Mediator, ILogger<CustomerController> logger)
        {
            Mediator = _Mediator;
            Logger = logger;
        }
        /// <summary>
        /// 客户管理添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public async Task<ApiResult<int>> CustomerAdd(CustomerAddCommand request)
        {
            Logger.LogInformation("客户管理添加");
            return await Mediator.Send(request);
        }
        /// <summary>
        /// 客户管理修改
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public async Task<ApiResult<int>> CustomerUpdate(CustomerUpdateCommand request)
        {
            return await Mediator.Send(request);
        }
        /// <summary>
        /// 客户管理删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public async Task<ApiResult<int>> CustomerDel([FromQuery]CustomerDelCommand request)
        {
            return await Mediator.Send(request);
        }
    }
}
